﻿using System;
namespace Producers.Rr.Xtee.Riik.Ee.Producer.Rr {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="RR41Request", Namespace="http://producers.rr.xtee.riik.ee/producer/rr", Target=typeof(RR41Request))]
    public class RR41RequestSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IRR41Request clazz;
        
        public RR41RequestSerializer(IRR41Request clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            Writer.WriteStartElement("isikuperenimi");
            if (clazz.Isikuperenimi!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Isikuperenimi))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Isikuperenimi");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("isikueesnimi");
            if (clazz.Isikueesnimi!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Isikueesnimi))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Isikueesnimi");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("isikukood");
            if (clazz.Isikukood!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Isikukood))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Isikukood");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("vald");
            if (clazz.Vald!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Vald))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Vald");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("Staatus");
            if (clazz.Staatus!=null) {
                Writer.WriteTypeAttribute("http://producers.rr.xtee.riik.ee/producer/rr", "isiku_staatus");
                Writer.WriteString(clazz.Staatus.ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Staatus");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("mitu");
            if (clazz.Mitu!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Mitu))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Mitu");
            }
            Writer.WriteEndElement();
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="isikuperenimi") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR41Request>isikuperenimi");
                }
                clazz.Isikuperenimi = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("isikuperenimi")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR41Request>isikuperenimi", Reader.LocalName);
            }
            if (Reader.LocalName=="isikueesnimi") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR41Request>isikueesnimi");
                }
                clazz.Isikueesnimi = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("isikueesnimi")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR41Request>isikueesnimi", Reader.LocalName);
            }
            if (Reader.LocalName=="isikukood") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR41Request>isikukood");
                }
                clazz.Isikukood = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("isikukood")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR41Request>isikukood", Reader.LocalName);
            }
            if (Reader.LocalName=="vald") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR41Request>vald");
                }
                clazz.Vald = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("vald")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR41Request>vald", Reader.LocalName);
            }
            if (Reader.LocalName=="Staatus") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR41Request>Staatus");
                }
                clazz.Staatus = new global::Producers.Rr.Xtee.Riik.Ee.Producer.Rr.IsikuStaatus(Reader.ReadElementString("Staatus"));
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR41Request>Staatus", Reader.LocalName);
            }
            if (Reader.LocalName=="mitu") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR41Request>mitu");
                }
                clazz.Mitu = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("mitu")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR41Request>mitu", Reader.LocalName);
            }
        }
    }
}
